import request from '@/config/axios'
import { ILoginUserInfoMap, IPutPassword } from './type'

const BASE_URL = '/userCenter/user'

/**
 * @description 登录
 * @param data
 */
export const loginApi = (data: LoginFormModule): Promise<IApiResponseData> => {
  return request.post({ url: `${BASE_URL}/login`, data })
}

/**
 * 退出登录
 */
export const logoutApi = (): Promise<IApiResponseData> => {
  return request.post({ url: `${BASE_URL}/logout` })
}

/**
 * 获取当前登陆用户
 */
export const getInfoApi = (): Promise<IApiResponseData<ILoginUserInfoMap>> => {
  return request.get({ url: `${BASE_URL}/current` })
}

/**
 * 修改密码
 */
export const putPassword = (data: IPutPassword) => {
  return request.put({ url: `${BASE_URL}/password`, data })
}
